<?php

namespace App\Http\Controllers\admin;

use App\Dao\ShopsDao;
use App\Services\Code;

class ShopsController extends BaseController
{

    public function lists(){
        if(getIsHasPage()){
            return Code::message('',200,ShopsDao::get_shop_pager(request()->all()));
        }

        return view('admin.shop.lists');
    }


    public function add(){
        if(isPost()){
            ShopsDao::add_shop(request()->all());
            return Code::message('',200);
        }
        return view('admin.shop.add');
    }

    public function edit(){
        if(isPost()){
            ShopsDao::edit_shop(request()->all());
            return Code::message('',200);
        }
        $info = ShopsDao::get_one([
            'shop_id'=>request('shop_id')
        ]);
        return view('admin.shop.edit',[
            'info'=>$info
        ]);
    }

    public function laike(){
        if(isPost()){
            ShopsDao::laike_shop(request()->all());
            return Code::message('',200);
        }
        $info = ShopsDao::get_one([
            'shop_id'=>request('shop_id')
        ]);
        return view('admin.shop.laike',[
            'info'=>$info
        ]);
    }

}
